package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-10
 * Time: 13:01
 */
public class Borrow implements Ioperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要借阅的书名");
        String bookName = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if (bookName.equals(book.getName())) {
                book.setBorrowed(true);
                System.out.println("借阅成功!!");
                return;
            }
        }
        System.out.println("没找到这本书");
    }
}
